package com.mvc.example;

import com.mvc.service.HelloService;
import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;

public class SpringMybatisExample {

    public static void main(String[] args){

        ApplicationContext context = new ClassPathXmlApplicationContext("applicationContext.xml");
//        UserDAO userDaoImpl = (UserDAO) context.getBean("userDAO");
//
//        SqlSessionTemplate sqlSessionTemplate = (SqlSessionTemplate) context.getBean("sqlSessionTemplate");
//        User user = sqlSessionTemplate.selectOne("com.mvc.dao.UserDAO.getUser", 1L);
//        System.out.println(user);
//
//
//        User user1 = userDaoImpl.getUser(2L);
//        System.out.println(user1);
//
////        RoleMapper roleMapper = (RoleMapper) context.getBean("roleMapper");
//        RoleDAO roleDAO = sqlSessionTemplate.getMapper(RoleDAO.class);
//        System.out.println(roleDAO.getRole(1L));
//
//        Map<String, String> param=new HashMap<>();
//        param.put("roleName","testName");
//        //mybatis逻辑分页
//        List<Map> roleList = roleDAO.findRoleByMap(param, new RowBounds(6, 5));
//        for(Map role : roleList) {
//            System.err.println("role_id=>"+role.get("id") + "\t role_ name=>"+role.get("role_name") );
//        }

        HelloService helloServiceImpl = (HelloService) context.getBean("helloServiceImpl");
        helloServiceImpl.showHello();

    }
}
